<?php

/* @var $this \yii\web\View */
/* @var $content string */

use app\assets\AppAsset;
use yii\helpers\Html;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <?= $content ?>
    </div>
</div>
<?php $this->endBody() ?>
<script>
    layui.config({
        base: 'layuiadmin/' //静态资源所在路径
    }).use(['layer'],function () {
        var layer = layui.layer;
        <?php if (\Yii::$app->session->getFlash('info')):?>
        setTimeout(function () {
            layer.msg("<?php echo \Yii::$app->session->getFlash('info') ?>");
        },400);
        <?php endif;?>

        //新tab窗口打开
        $("a.newTab").click(function () {
            var url = $(this).attr('lay-href');
            var tit = $(this).text();
            if(top.layui.index){
                top.layui.index.openTabsPage(url,tit)
            }else{
                window.open(url)
            }
        })

        //监听
        window.chanspy = function(exten,type) {
            layer.confirm('请确认已分配了分机并登录成功？',function() {
                $.post('<?php echo \yii\helpers\Url::to(['report/chanspy']); ?>',{exten:exten,type:type},function(res) {
                    layer.msg(res.msg,{time:2000})
                });
            })
        }

        //呼叫
        window.call = function (phone) {
            <?php if (Yii::$app->user->identity->exten){ ?>
                layer.confirm('请确认已分配了分机并登录成功？',function() {
                    $.post('<?php echo \yii\helpers\Url::to(['api/dial']); ?>',{exten:<?php echo Yii::$app->user->identity->exten; ?>,phone:phone},function(res) {
                        layer.msg(res.msg,{time:2000})
                    });
                });
            <?php }else{ ?>
                layer.msg("您未绑定分机号，请先绑定");
            <?php } ?>
        }

    })
</script>
</body>
</html>
<?php $this->endPage() ?>
